<%-- 
    Document   : TransferPage
    Created on : 17/Jan/2010, 2:17:40
    Author     : Marco
--%>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>

<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
   "http://www.w3.org/TR/html4/loose.dtd">

<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>Operações de Transferência</title>
        <script type="text/javascript" type="javascript">
        function operationTypeChanged(select) {
            switch (select.value) {
                //Transfer
                case "Transfer": {
                   document.getElementById("originAccountLine").style.visibility = "visible";
                   document.getElementById("destinAccountLine").style.visibility  = "visible";
                   select.form.originAccount.disabled = false;
                   select.form.destinAccount.disabled = false;
                } break;
                //Withdraw
                case "Withdraw": {
                   document.getElementById("originAccountLine").style.visibility = "visible";
                   document.getElementById("destinAccountLine").style.visibility  = "hidden";
                   select.form.originAccount.disabled = false;
                   select.form.destinAccount.disabled = true;
                } break;
                //CheckDeposit
                case "CheckDeposit": {
                   document.getElementById("originAccountLine").style.visibility = "visible";
                   document.getElementById("destinAccountLine").style.visibility  = "visible";
                   select.form.originAccount.disabled = false;
                   select.form.destinAccount.disabled = false;
                } break;
                //MoneyDeposit
                case "MoneyDeposit": {
                   document.getElementById("originAccountLine").style.visibility = "hidden";
                   document.getElementById("destinAccountLine").style.visibility  = "visible";
                   select.form.originAccount.disabled = true;
                   select.form.destinAccount.disabled = false;
                } break;
            }
        }
        </script>
        <style type="text/css">
            .error {
                border-color:red;
                border-style:solid;
                border-width:thin;
            }
        </style>
    </head>

    <body>
        <h1>${requestScope['title']}</h1>
        <form action="${requestScope['contextPath']}" method="POST">
        <table>
            <tr>
                <td>Operação</td>
                <td>
                    <select name="operationType" onchange="operationTypeChanged(this);">
                        <option value="Transfer" <% %>>Transferência</option>
                        <option value="Withdraw">Levantamento</option>
                        <option value="CheckDeposit">Depósito Cheque</option>
                        <option value="MoneyDeposit">Depósito Dinheiro</option>
                    </select>
                </td>
            </tr>
            <tr id="originAccountLine">
                <td>Conta origem</td>
                <td><input name="originAccount" type="text" maxlength="21" size="25"/></td>
            </tr>
            <tr id="destinAccountLine">
                <td>Conta destino</td>
                <td><input name="destinAccount" type="text" maxlength="21" size="25"/></td>
            </tr>
            <tr>
                <td>Valor</td>
                <td><input name="value" type="text" maxlength="12" size="15"/> &euro;</td>
            </tr>
            <tr>
                <td><input type="button" value="Efectuar" onclick="this.form.action=''; this.form.submit();"/></td>
                <td><input type="button" value="Cancelar" onclick="this.form.submit();"/></td>
            </tr>
        </table>
        </form>
        <c:choose>
            <c:when test="${!empty(requestScope['formError'])}">
                <div class="error">${requestScope['formError']}</div>
            </c:when>
        </c:choose>
    </body>
</html>
